package cc.wman.data.common.command;

import java.lang.reflect.InvocationTargetException;

/**
 * Copyright (C),big-data
 * FileName: InnerCommandContext
 * Author:   maokai
 * Date:     2020/2/20 10:30
 * Description:
 */
public class InnerCommandContext {

    public InnerCommand getInstance(String command){
        try {
            return CommandEnum.getCommandInstance(command);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        InnerCommandContext context = new InnerCommandContext();
        InnerCommand instance = context.getInstance("1");
        instance.sout("");
        InnerCommand instance1 = context.getInstance("2");
        instance1.sout("");
        InnerCommand instance2 = context.getInstance("3");
        instance2.sout("");
        InnerCommand instance3 = context.getInstance("4");
        instance3.sout("");
    }
}
